export default function objectToFormString(data: object): string {
    let formString = '';
    const keys = Object.keys(data);
    for (let i = 0; i < keys.length; i++) {
        const key = keys[i];
        const value = (data as any)[key];
        if (Array.isArray(value)) {
            // 如果属性值是数组，将其转换为多条表单项
            for (let j = 0; j < value.length; j++) {
                formString += `${encodeURIComponent(key)}[]=${encodeURIComponent(value[j])}&`;
            }
        } else {
            formString += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
        }
    }
    // 去除末尾的 "&" 字符
    return formString.slice(0, -1);
}